﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
         xmlns:db="http://www.springframework.net/database">
  <!-- 用以我们在其它的应用程序中，配置数据访问 -->
  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="databaseSettings"/>
  </object>

  <!-- 数据库和Nhibernate的相关配置 -->
  <db:provider id="DbProvider" provider="SqlServer-1.1"
               connectionString="Server=${db.datasource};database=${db.database};uid=${db.user};pwd=${db.password};"/>

  <!--SessionFactory对象，其中包括一些比较重要的属性 -->
  <object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate21">
    <property name="DbProvider" ref="DbProvider"/>
    <property name="MappingAssemblies">
      <list>
        <value>SimCMS.Model</value>
      </list>
    </property>
    <property name="HibernateProperties">
      <dictionary>
        <entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        <entry key="dialect" value="NHibernate.Dialect.MsSql2000Dialect"/>
        <entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/>
        <entry key="use_outer_join" value="true"/>
        <entry key="show_sql" value="false"/>
        <!--自动建表(反向映射)-->
        <entry key="hbm2ddl.auto" value="update"/>
        <entry key="adonet.batch_size" value="10"/>
        <entry key="command_timeout" value="60"/>
        <!--显式启用二级缓存-->
        <entry key="cache.use_second_level_cache" value="false"/>
        <!--启动查询缓存-->
        <entry key="cache.use_query_cache" value="false"/>
        <entry key="query.substitutions" value="true 1, false 0, yes 'Y', no 'N"/>
        <entry key="proxyfactory.factory_class" value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"/>
      </dictionary>
    </property>
    <property name="ExposeTransactionAwareSessionFactory" value="true" />
  </object>

  <object id="HibernateTemplate" type="Spring.Data.NHibernate.Generic.HibernateTemplate">
    <property name="SessionFactory" ref="NHibernateSessionFactory" />
    <property name="TemplateFlushMode" value="Auto" />
    <property name="CacheQueries" value="false" />
  </object>

  <object id="SimCMS.Repository.Simadmin" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simadmin>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.Simadminmenu" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simadminmenu>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.Simadminrole" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simadminrole>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.Simchildobj" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simchildobj>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.Simobjattr" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simobjattr>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.Simobjsattr" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.Simobjsattr>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.SimFCategory" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.SimFCategory>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
  <object id="SimCMS.Repository.SimFoodmenu" type="SimCMS.Repository.NHibernateRepository&lt;SimCMS.Model.SimFoodmenu>, SimCMS.Repository">
    <property name="HibernateTemplate" ref="HibernateTemplate"/>
  </object>
</objects>